<template>
  <el-dialog title="问题查询" :close-on-click-modal="false" :visible.sync="visible" fullscreen center append-to-body>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-table :data="dataList" height="calc(100vh - 215px)" ref="singleTable" border v-loading="dataListLoading">
      <el-table-column type="index" width="50">
        <template slot-scope="scope">
          <el-radio v-model="probleId" :label="scope.row.id" style="position: relative;left: 6px;top:-2px;" @change="checkitem(scope.row)">&nbsp;</el-radio>
        </template>
      </el-table-column>
      <el-table-column prop="problemName" label="问题名称"></el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
  import {filterParams} from '@/util/tools'
  import { getQuestionList } from '@/api/mp/wxevaluateproblem'
  export default {
    data () {
      return {
        visible: false,
        probleId: '',
        list: [],
        dataList: [],
        dataListLoading: false
      }
    },
    methods: {
      init(list) {
        this.visible = true
        if(list){
          this.list = JSON.parse(list)
        }
        this.probleId = ''
        this.getDataListt()
      },
      getDataListt() {
        getQuestionList().then(result => {
          this.dataList = result.data.data
        })
      },
      // 选择品种
      checkitem(val) {
        if(this.list.indexOf(val.id) == -1){
          this.visible = false
          this.$emit('refreshData',val)
        }else{
          this.$message.warning('该问题已存在')
        }
      },
    }
  }
</script>

<style>
</style>
